<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>前端cookie框架测试</title>
  </head>

  <body>
    key:<input type="text" id="ipKey" /><br />
    value:<input type="text" id="ipValue" /><br />
    maxAge:<input type="text" id="ipMaxAge" /><br />
    <button id="btnSet">设置cookie</button>
    <button id="btnDelete">删除cookie</button>
    <button id="btnAll">获取全部cookie</button>
    <button id="btnGet">获取指定cookie</button>
    <p id="pValue">JSON</p>

    <script src="./cookies.js"></script>
    <script>
      btnSet.onclick = function (e) {
        setCookie(ipKey.value, ipValue.value, ipMaxAge.value * 1);
      };

      btnDelete.onclick = function(e){
        deleteCookie(ipKey.value)
      }

      btnAll.onclick = function(e){
        const obj = getAllCookie()
        pValue.innerText = JSON.stringify(obj)
      }

      btnGet.onclick = function(e){
        pValue.innerText = getCookie(ipKey.value)
      }
    </script>
  </body>
</html>
